<script language="javascript">
	function funTrangThai(SID){
		window.location='?mod=gopy&SID=' + SID;
	}
</script>
<?
if(isset($_GET['method']))
{
	$method = $_GET['method'];
	if($method=="del"){
		$sListId="";
		if(isset($_POST["chon"]))$sListId=$_POST["chon"];
		$sql="delete from ".$prefix."gopy where bl_id in('".str_replace(",","','",$sListId)."')";
		mysql_query($sql);
		Redirect("Bạn đã xoá thành công","?mod=gopy");	
	}else if($method=="act"){
		$IdList=$_GET["id"];
		$act=$_GET["act"];
		if($act==1) $iact=0;else $iact=1;
		$sql="update ".$prefix."gopy set bl_tinhtrang=$iact where bl_id=$IdList";
		mysql_query($sql);
		Redirect("","?mod=gopy");		
	}else if($method=="delete"){
		$IdList=$_GET["id"];
		$sql="delete from ".$prefix."gopy where bl_id=$IdList";
		mysql_query($sql);
		Redirect("Đã xóa thành công","?mod=gopy");		
	}
}
	$strSQL = "select * from ".$prefix."gopy";
	
	if(isset($_GET['SID']) && ($_GET['SID'] != 3) ){
		$SID = intval($_GET['SID']);
		$strSQL .= " WHERE bl_tinhtrang = '".$SID."'";
	}else{
		$SID = 3;
	}
	///////Paging
	$pp=10; 
	$parr=array();
	$parr=paging($strSQL,$pp);
	$page=$parr[0];
	$limitvalue=$parr[1];
	$numofpages=$parr[2];
	$strSQL .= " order by bl_id DESC";
	$strSQL.=" LIMIT $limitvalue, $pp";
	$rs = $db->query($strSQL);
	$i=0;
	$isexits=false;
	
	if(mysql_num_rows($rs)) $isexits=true;
?>
<div class="newsList-path"></div>
	<div style="margin-bottom:5px; font-size:14px;">
	 Có <?=$db->num_rows($rs)?>
	  góp ý được tìm thấy </div>
	<div align="right" class="newsList-search-up">&nbsp;
	  <select name="FilterByStatus" id="SID" onchange="return(funTrangThai(this.value));">
	<option value="3" <? if($SID == 3){ ?> selected="selected" <? } ?>>--Trạng thái--</option>
	<option value="1" <? if($SID == 1){ ?> selected="selected" <? } ?>>Đã xử lý</option>
	<option value="0" <? if($SID == 0){ ?> selected="selected" <? } ?>>Chưa xử lý</option>
	  </select>
</div>
<form name="frmListSp" method="post" action="?mod=gopy&method=del" onSubmit="return checkInput(this,'Bạn hãy chọn ít nhất một giá trị','Bạn chắc chắn muốn xoá không');">
	<input type="hidden" name="chon" />
	<table width="100%" border="1" bordercolor="#B2DAEE" cellpadding="4">
		<tr class="newsList-content-head">
		<td width="4%" class="newsList-content-view"><input type="checkbox" name="chkall" value="0" <? if($isexits) echo "onClick=\"docheck(this.form,0);\""?>></td>
			<td width="23%" class="newsList-content-title">Chủng loại </td>
			<td width="26%" class="newsList-content-title">Liên kết </td>
		    <td width="28%" class="newsList-content-title">Chi tiết </td>
		    <td width="10%" class="newsList-content-view"><div align="center">Trạng thái </div></td>
	      <td width="9%" class="newsList-content-view"><div align="center">Tùy chọn </div></td>
		</tr>
				<?
				while($rows = $db->fetch_array($rs))
				{
					$i++;
					$bl_id = $rows['bl_id'];
					$bl_link = $rows['bl_link'];
					$bl_cat = $rows['bl_cat'];
					$bl_chitiet = $myString->unQuote(stripslashes($rows['bl_chitiet']));
					$bl_tinhtrang = $rows[bl_tinhtrang];
				?>				
		<tr onmouseover="this.bgColor='#FEF2CB';" onmouseout="this.bgColor='#FFFFFF';" class="newsList-content-list" <? if($i%2==0) echo "bgcolor='#f2fff2'";?>>
			<td class="newsList-content-title"><input type="checkbox" name="Xoa" value="<?=$bl_id?>" onClick="docheckone(this.form);"></td>
			<td class="newsList-content-title"><?=loadLoaiGopY($bl_cat)?></td>
			<td class="newsList-content-title">
            	<table cellpadding="0" cellspacing="0" width="100%">
                <tr>
					<td>
						<a class="newsList-link newsList-name" href="<?=$bl_link?>">
						<?=$bl_link?></a>					</td>
              </table>			</td>
		    <td class="newsList-content-title"><table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                  <td><?=$bl_chitiet?> </td>
                </tr>
		      </table></td>
		    <td class="newsList-content-view"><div align="center"><a href="?mod=gopy&method=act&act=<?=$bl_tinhtrang;?>&id=<?=$bl_id?>"><?=ImgActive($bl_tinhtrang);?></a></div></td>
	      <td class="newsList-content-view"><div align="center">
		 
		  <a href="?mod=gopy&amp;method=delete&amp;id=<?=$bl_id?>" class="menu" onclick="return confirm('Bạn có chắc chắn muốn xóa không?')"><img src="images/delete_on.gif" border="0" /></a></div></td>
        </tr>
		<? }?>
	<tr>
   <td colspan="13" align="center">
   <input type="submit" name="submit" value="   Xoá   " class="Button">
   <input type="reset" value="Làm lại" class="Button">   </td>
   </tr>
</table>
</form>
	<div class="newsList-pagging">
	<div class="raovat-paging-bound">
	<span style="padding:5px;">
	<p align="center" class="font">
			<?php echo page_div( "?mod=gopy&p=%d_pg", "10", ceil ( $numofpages ), $page ); ?>
	</p>
	</span>
	</div>
	</div>
	<div class="newsList-button-back"><a href="javascript: history.back()">[Quay lại]</a></div>